public class Solution3 {
    public static void main(String[] args) {
        ListNode head = null;
        System.out.println(reverseList(head));
    }
    public static ListNode reverseList1(ListNode head) {
        if(head == null) {
            return null;
        }
        ListNode cur = head.next;
        head.next = null;
        while(cur != null) {
            ListNode curNext = cur.next;
            cur.next = head;
            head = cur;
            cur = curNext;

        }
        return head;
    }

    public static ListNode reverseList(ListNode head) {
        if(head == null || head.next == null) {
            return head;
        }
        ListNode newHead = reverseList(head.next);
        head.next.next = head;
        head.next =null;
        return newHead;
    }
}
